home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-04-20 | 30.7 KB | 1,099 lines |
- TITLE 'DRIVER...Console out file driver'
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- \\\This demonstration source code is copyrighted and is for the \\\
- \\\express use of FUTURE86 users persuant to the terms of the \\\
- \\\FUTURE86 license. \\\
- \\\ \\\
- \\\Copyright (C)1987 Development Associates \\\
- \\\All rights reserved \\\
- \\\ \\\
- \\\This source code may be evaluated by potential FUTURE86 \\\
- \\\users to determine product suitability. \\\
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- \\\Some resources in this file are not utilized by \\\
- \\\the demonstration program. \\\
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- \\\ RFD Revised 4-02-87 --general file cleanup \\\
- \\\ 4-17-87 --added recoding examples \\\
- \\\ 4-18-87 --added cpu timing independence \\\
- \\\ 4-19-87 --added scale music \\\
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- PAGE
-
- \\\Define system constants, etc..
-
- ESCAPE EQU 27 \ESCAPE key
-
- SCREENSIZE DW 184FH \18=hex rows, 4F=columns
-
- CRTATR DB 07 \VIDEO Attribute
-
- PAGE# EQU 0:462H \DOS page addr
-
- LRCORN EQU 217 \CODE for LR char
-
- ULCORN EQU 218 \CODE for UL char
-
- LLCORN EQU 192 \CODE for LL char
-
- URCORN EQU 191 \CODE for UR char
-
- \\\SCREEN ATTRIBUTE CONTROL\\\
-
- : GET_ATR
- CRTATR B@ SWAP ; \get ATR & put under mask
-
- \NOTE: THESE MODES CAN BE MIXED
-
- : VSET \logical OR
- GET_ATR FOR
- CRTATR B! ;
-
- : VCLR \logical AND
- GET_ATR FAND
- CRTATR B! ;
-
- PAGE
-
- \THE NEXT WORDS SET UP THE VIDEO ATRIBUTES BUT DO NOT CAUSE
- \ANY ACTION UNTIL EITHER FCO OR XCO AND THEIR DERIVATIVES
- \ARE USED(these words are defined later in this file)
-
- : NORM \normal video attribute
- 7 VCLR
- 7 VSET ;
-
- : INTENS \intensified chars
- 01000B VSET ;
-
- : -INTENS \cancel intensity
- 11110111B VCLR ;
-
- : BLINK \char blinking
- 10000000B VSET ;
-
- : -BLINK \cancel char blink
- 1111111B VCLR ;
-
- : REVERSE \reverse video
- 01110000B VSET
- 11111000B VCLR ;
-
- : -REVERSE \cancel reverse video
- 111B VSET
- 10001111B VCLR ;
-
-
- : BLACK \dark screen--no chars
- 10001000B VCLR ;
-
- : WHITE \bright screen--no chars
- 01110111B VSET ;
-
- PAGE
-
- \\\DEFINE INT 10H STRUCTURE
-
- : INT_10H
- 10H SET_INT_NO
- !AH
- SYSTEM_CALL
- RESTORE_INT_NO ;
-
- \\\SET VIDEO MODE
-
- \NOTE THAT PROCEDURE NAMES CAN BE SELECTED TO DOCUMENT TO ANY
- \DESIRED LEVEL--THERE REALLY CAN NOT BE ANY DOUBT ABOUT WHAT THE
- \NEXT FEW WORDS DO
-
- \EQU FOR VIDEO MODE SELECTION
- 40X25_BW EQU 0
- 20X25_COLOR EQU 1
- 80X25_BW EQU 2
- 320X200_COLOR EQU 3
- 320X200_BW EQU 4
- 320X200_GRAPH EQU 5
- 640X200_GRAPH EQU 6
- 80X25_MONO EQU 7 \mono card only
-
- : SET_VIDEO_MODE \mode ---
- !AL \store mode
- 0 \operation type
- INT_10H ;
-
- PAGE
-
- \\\SET ACTIVE PAGE#\\\
-
- : ?PAGE#
- PAGE# B@ ; \Get active page no.
-
- : SET_PAGE# \PAGE# ---
- \page no. = 0--3 for CGA
- !AL
- 5 INT_10H ;
-
- \\\FORCE CURSOR POSITION
-
- : PUT_CURS \ row colm ---
- !DL \colm
- !DH \row
- ?PAGE# !BH
- 2 INT_10H ;
-
- \\\FIND CURSOR POSITION\\\
-
- : GET_CURS \ --- Attrib row colm
- ?PAGE# !BH
- 3 INT_10H
- @CX \get atr
- @DH \get row
- @DL ; \get colm
-
- : HOME \move cursor to upper left of screen
- 0 !DX
- ?PAGE# !BH
- 2
- INT_10H ;
-
- \\\CLEAR DESIRED SCREEN AMOUNT\\\
-
- : CLR \srow scolm erow ecolm
- 0 !AL
- !DL \ecolm
- !DH \erow
- !CL \sclm
- !CH \srow
- CRTATR B@ !BH \crtatr
- 6 INT_10H ;
-
- PAGE
-
- \\\READ SCREEN CHAR AT CURSOR\\\
-
- : READ_CHAR/AT \ --- atr char
- ?PAGE# !BH \page no.
- 8 INT_10H
- @AH \atr
- @AL ; \char
-
- \\\WRITE SCREEN CHARS AT CURSOR\\\
-
- : WRITE_CHAR/AT \char size ---
- ?PAGE# !BH \page no.
- !CX \no. of chars to write
- !AL \char
- CRTATR B@ !BL \atr
- 9 INT_10H ;
-
- : WRITE_ATR \ ---
- READ_CHAR/AT \ get char & atr at curs pos
- DROP2ND
- 1
- WRITE_CHAR/AT ; \rewrite char w/new atr
-
- : CLR_SCREEN \CLEAR ENTIRE SCREEN
- 0 0
- 24 79 CLR ;
-
- : CLS \same as IBM CLS
- HOME CLR_SCREEN ;
-
- : BEL \ring computer bell
- 7 CO ;
-
- \\\SCROLL CONTROL
-
- : SCROLL_UP_LINES \n1(lines to scroll up) ---
- !AL \no. lines to scroll
- 0 !CX \start scroll at UL corner
- SCREENSIZE @ !DX \end row,column of scroll
- CRTATR B@ !BH \atr used on blank line
- 6 INT_10H ;
-
- : SCROLL_UP_ONE_LINE
- 1 SCROLL_UP_LINES ;
-
- PAGE
-
- \\\The next word, FCO, is a console out procedure and is written mostly
- \in assembly language for maximum speed. This has the same function
- \as the kernel word CO but is faster. An even faster and less
- \portable method would be a direct hardware access but that should
- \not be used except in the most time critical applications.
- \A word that follows, XCO, is a mix of high level and assembly.
- \FCO runs much faster than XCO which shows the speed advantage
- \that low level code can yield. However, XCO is much more readable
- \and was obviously easier to write. In fact, FCO was written after
- \XCO was developed and was used as the basis for coding FCO. this is
- \a good example of a valid development technique--first prototyping in
- \high level and then--if the application requires-rewriting in assembler.
-
- \Note the use of local labels signified by the "_" character
- \in front of the label.
-
- : FCO
- PUSH ES \preset es:=0
- MOV AX,0 \= DOS low memory
- MOV ES,AX
- MOV AH,3 \get cursor pos.
- MOV BH,BYTE ES:PAGE# \get current disp. page
- PUSH BP
- INT 10H
- POP BP
- \
- MOV AL,[BP] \load the character
- CMP AL,0DH \CR?
- JNE _FCO_BS \branch if not
- MOV DL,0 \clear column reg.
- JMP _FCO2 \set cursor and return
- _FCO_BS:
- CMP AL,08 \BS?
- JNE _FCOLFX \branch if not
- CMP DL,0 \far left colmn?
- JE _FCO2 \branch if so
- DEC DL \else decrement cursor
- JMP _FCO2 \set cursor & return
- _FCOLFX:
- CMP AL,0AH \LF?
- JE _FCO_LF \branch if so
- _?BEL: CMP AL,7
- JNE _FCO_CHR
- _BEL:
- BEL \speed not important; so hi level
- JMP _XDN \now drop stack and exit
- \
-
- PAGE
-
- _FCO_CHR:
- PUSH DX \save current cursor
- MOV AH,9 \write current atr & chr
- MOV BL,BYTE CS:CRTATR \get char attribute
- MOV BH,BYTE ES:PAGE# \get page no.
- MOV CX,1 \char count
- PUSH BP
- INT 10H
- POP BP
- POP DX \get current cursor
- INC DL \advance colmn
- CMP DL,80 \colmn limit?
- JNZ _FCO1 \branch if not
- MOV DL,0 \set far left position
- _FCO_LF:
- INC DH \advance row
- _FCO1: CMP DH,24 \row limit?
- JLE _FCO2 \branch if not
- MOV DH,24 \set bottom position
- PUSH DX \save cursor position
- MOV AX,601H \scroll up one line
- MOV CX,0 \left upper corner
- MOV DX,CS:SCREENSIZE \right lower corner
- MOV BH,CS:CRTATR \attribute
- PUSH BP
- INT 10H
- POP BP
- POP DX \get cursor position
- _FCO2:
- MOV AH,2 \set new cursor position
- MOV BH,BYTE ES:PAGE# \active display page
- PUSH BP
- INT 10H
- POP BP
- _XDN: ADD BP,4 \clean stack
- POP ES ; \finally, the end of FCO
-
- PAGE
-
- \\\XCO IS A GOOD EXAMPLE OF MIXING ASSEMBLY AND HI-LEVEL IN A MODELESS
- \WAY THAT IS NATURAL WITH FUTURE86.
-
- : XCO
- ?PAGE# !BH \select page no.
- 3 INT_10H
- @DH
- 24 <
- IF
- JMP _OUTPUT \branch if now row limit
- ELSE
- SCROLL_UP_ONE_LINE \hi-level scroll..but just once/line
- 23 0 PUT_CURS \adjust cursor position
- THEN
- _OUTPUT: \this is local label
- WRITE_ATR \put the character attribute
- CO ; \write the character
-
- \STRING OUTPUT VERSION THAT USES FCO
-
- : FPRINTS
- BEGIN \string(addr,length)---
- ?NULL
- -IF
- CGET FCO
- REPEAT ;
-
- : BACK_UP \backspace, nondestructive
- 08 FCO ;
-
- : FCRLF
- 10 FCO \line feed
- 13 FCO ; \carriage return
-
- \GENERATE MULTIPLE CRS
-
- : CRS \ n ---
- DO
- FCRLF
- LOOP ;
-
- : DRAW \ char # ---
- DO
- DUP FCO
- LOOP DROP ;
-
- : SEP \make a line of '=' marks
- 205 80 DRAW ;
-
- PAGE
-
- \\\PRIMATIVE TEXT LINES\\\
-
- : LF \linefeed
- 10 FCO ;
-
- : H_BIT \make a '-'
- 196 FCO ;
-
- : V_BIT \make a vertical mark
- 179 FCO ;
-
- : HLINE \horiz line from curs pos
- 1 MAX
- DO
- H_BIT
- LOOP ;
-
- : VLINE \vert line from curs pos
- GET_CURS
- DSWAP DROP
- 1 MAX
- DO
- DDUP PUT_CURS
- V_BIT
- 1+2ND
- LOOP
- DDROP ;
-
- : LIMIT
- 2 MAX 2 - ;
-
- : SETUP_BOX \manipulate stack
- DSWAP LIMIT
- SWAP LIMIT
- SWAP DSWAP DDUP
- PUT_CURS ;
-
- PAGE
-
- : TOP_LINE \draw top horiz
- ULCORN FCO
- 4 PICK HLINE
- URCORN FCO
- BACK_UP
- LF ;
-
- : RVERT_LINE \draw right vert
- 3 PICK VLINE ;
-
- : LVERT_LINE \draw left vert
- PUT_CURS LF
- VLINE
- BACK_UP
- LLCORN FCO ;
-
- : BOT_LINE \draw bot horiz
- HLINE LRCORN FCO ;
-
- : BOX \horizlen vertlen row colm --- box
- SETUP_BOX \horizlen = 80 MAX
- TOP_LINE \vertlen = 24 MAX
- RVERT_LINE
- LVERT_LINE
- BOT_LINE ;
-
- PAGE
-
- \\\SOUND\\\
-
- TMR_MDE_REG EQU 0B6H \timer mode register
-
- TM_MDE_PRT EQU 43H \timer mode port
-
- SCALE EQU 1221 \freq scale# for IBM PC
-
- TMR2_PRT EQU 42H \timer 2 port
-
- PRTB EQU 61H \timer port B
-
- SPK_ON EQU 03 \'on' command code
-
- SPK_OFF EQU 1 \'off' command code
-
- SAVEIT DW 0 \command save bucket
-
- : SETUP \ --- ; init reg & port
- TMR_MDE_REG
- TM_MDE_PRT
- FOUT ;
-
- : FREQ \ freq ---
- SCALE
- 1000 D*
- SWAP D/
- DUP TMR2_PRT
- FOUT
- 8 SR
- TMR2_PRT FOUT ;
-
- : SOUND_ON \ --- ;activate tone generator
- PRTB FIN DUP
- SAVEIT !
- SPK_ON
- FOR
- PRTB FOUT ;
-
- PAGE
-
- : OFF \turn tone off
- SAVEIT @
- PRTB FOUT ;
-
- : TONE_CHANGE \ freq --- ;to change tone pitch
- SETUP FREQ ;
-
- : TONE \freq, in cps ---
- TONE_CHANGE
- SOUND_ON ;
-
- \\\equates for musical notes, cps
- CNXT EQU 528
- ANAT EQU 440
- BNAT EQU 495
- GNAT EQU 396
- FNAT EQU 352
- ENAT EQU 330
- DNAT EQU 297
- CNAT EQU 264
-
-
-
- PAGE
-
- \ This section displays the contents of a text file.
- \ By use of a separate script file each character
- \ output can be controlled as to format and speed and
- \ screen placement.
- \ Script file contains the following characters
- \ that change the output text mode as follows:
-
- \ a ... normal output, next 3 bytes = #chars to output
- \ b ... inverse output, "
- \ c ... blink output, "
- \ d ... intensity, "
-
- \ e ... Reset delay
- \ f ... set shortest delay
- \ g ... set longer delay
- \ h ... set longer delay
- \ i ... set longest delay
-
- \ j ... clear screen, put cursor at 0 0
-
- \ k ... move cursor, next 2 bytes are x,y
- \ l ... send prompt message to screen and wait for input
- \ m ... output string(no format change), next 3 bytes=#chars
- \ n ... make a computer bell
- \ o ... execute programmed delay
- \ p ... draw a box, next 4 bytes are ysize,xsize,row,colm
- \ q ... switch to 1st display page
- \ r ... switch to 2nd display page
- \ s ... make programmed tone
- \ t ... turn tone off
- \ u ... make a click
- \ v ... clr desired part of screen,
- \ next 4 bytes are srw,sclm,erw,eclm
- \ X ... programmed end of program...outputs message to crt.
- \ CR and other characters in the script
- \ file are disregarded
-
- PAGE
-
- CTLC EQU 3
-
- EXIT_FLG DSW
-
- OUTPUT_COUNT DSW
-
- FILE_SIZE EQU 25000
-
- SCRIPT_BUF DSB 4000 \script buffer reservation
-
- FILE_BUF DSB FILE_SIZE \text file buffer reservation
-
- : SET_EXIT
- EXIT_FLG 1! ;
-
- \\\Programmed delay...insensitive to cpu clock speed
- \\\Please note: FUTURE86 makes this easier than in most
- \\\other languages..we do not need to save and then restore
- \\\all sorts of machine status to do this
-
- DELAY_TIME DW 0 \variable for needed delay
-
- TIMER_INT EQU 70H \01CH * 4..user timer vector
-
- TIMER_COUNT DW 0 \counter bucket
-
- ORIG_VECTOR DD 0 \save loc. for orig addr
-
- : TIMER_DONE \reset bucket
- TIMER_COUNT 0! ;
-
- : SET_ORIG_VECTOR \restore user vector
- ORIG_VECTOR D@
- TIMER_INT D! ;
-
- \next is in assembler for low overhead during timer tick
- : INC_TIMER \this is new user code
- TIMER_VECTOR: \ref. addr label
- INC CS:TIMER_COUNT \new entry point
- IRET \done
- ;
-
- PAGE
-
- : SET_NEW_VECTOR \install the user vector
- TIMER_VECTOR
- TIMER_INT D! ;
-
- : SAVE_ORIG_VECTOR \save so we know what to put back
- TIMER_INT D@
- ORIG_VECTOR D! ;
-
- : SET_DELAY \ n1 --- (each # is approx 55 ms)
- DELAY_TIME !
- 0 ;
-
- : ?TIMER_DONE \stay here until we time out
- BEGIN
- TIMER_COUNT @
- DELAY_TIME @
- > DUP
- IF
- SET_ORIG_VECTOR
- TIMER_DONE
- THEN
- UNTIL ;
-
- : DELAY \programmable delay
- DELAY_TIME @
- IF
- SET_NEW_VECTOR \turn on timer
- ?TIMER_DONE \wait till done and continue
- THEN ;
-
- : INIT_TIMER \this saves orig vector and initializes
- SAVE_ORIG_VECTOR
- TIMER_COUNT 0!
- DELAY_TIME 0! ;
-
- \\\PLAY THE SCALE
-
- : DURATION
- 3 SET_DELAY DROP DELAY ;
-
- : NOTE
- TONE DURATION OFF ;
-
- : PLAY
- 8 DO NOTE LOOP ;
-
- : SCALE_DOWN
- CNAT
- DNAT
- ENAT
- FNAT
- GNAT
- ANAT
- BNAT
- CNXT ;
-
- : SCALE_UP
- CNXT
- BNAT
- ANAT
- GNAT
- FNAT
- ENAT
- DNAT
- CNAT ;
-
- \if below is executed by itself..be sure to execute INIT_TIMER first
- : SCALE_UP/DOWN
- SCALE_DOWN
- SCALE_UP
- 2
- DO
- PLAY
- LOOP ;
-
- \the commented out code is used if just software delay is used
- \: SET_DELAY
- \ DELAY_TIME ! 0 ;
-
-
- \: DELAY \programmable delay
- \ DELAY_TIME @
- \ IF
- \ DELAY_TIME @
- \ DO
- \ LOOP
- \ THEN ;
-
- PAGE
-
- \\\Misc. text messages
- : FPRINTS+CRS
- FCRLF FPRINTS FCRLF ;
-
- : ESC_MSG
- "Esc key depressed..." ;
-
- : OUTPUT_ESC_MSG
- ESC_MSG FPRINTS+CRS ;
-
- : ?USER_KEY \test for user Esc key depress
- CONSTS
- IF
- DCI ESCAPE =
- IF
- OUTPUT_ESC_MSG
- SET_EXIT
- THEN
- THEN ;
-
- \Output string to monitor with program. interchar delay
- : CPRINTS \sinfo ---
- BEGIN
- CGET
- DELAY FCO
- ?NULL
- -IF
- REPEAT ;
-
- : RETMSG
- FCRLF 4 SPACES
- " Press Esc key to abort or SPACE bar to continue..."
- INTENS REVERSE
- FPRINTS NORM
- BEGIN DCI
- DUP 32 = SWAP
- ESCAPE = DUP
- EXIT_FLG ! FOR
- UNTIL
- EXIT_FLG @
- IF FCRLF
- OUTPUT_ESC_MSG
- THEN ;
-
- PAGE
-
- : FATAL_ERROR_COND \ ---
- FCRLF DISPLAY_ERR_MSG
- FCRLF RETMSG REBOOT ;
-
- : TEST_ERROR \cond ---
- -IF
- FATAL_ERROR_COND
- THEN ;
-
- : ?OPEN_FILE \ ---
- GET_ARG
- OPEN
- TEST_ERROR ;
-
- : OPEN_FILES
- ?OPEN_FILE SET#1 \open text file
- ?OPEN_FILE SET#2 ; \open script file
-
- : CLOSE_FILES \ ---
- #1 CLOSE DROP \ignore error flags
- #2 CLOSE DROP ;
-
- : READ_TEXT_FILE \ --- sinfo
- FILE_BUF FILE_SIZE
- #1 READ TEST_ERROR ;
-
- \ --- sinfo(txt) sinfo(script)
- : READ_FILES
- READ_TEXT_FILE
- SCRIPT_BUF 4000 #2 READ
- TEST_ERROR ;
-
- PAGE
- \The next few words are examples of how much easier coding
- \in FUTURE86 can be. The commented out (with the '\' character)
- \definitions are coded in high level FUTURE86 and is quite efficient,
- \but active definitions that follow with the same names are
- \coded at even a higher level that really simplifies the
- \code and its readability.
-
- \: 3BYTE# \sinfo --- sinfo
- \ OVER \get starting address of no.
- \ 3 \string is 3 bytes long
- \ DECIMAL-BIN \convert to bin. no.
- \ DROP \assume success, drop flag
- \ OUTPUT_COUNT ! \save converted value to variable
- \ SWAP \get original addr of string
- \ 3 + \push it up by no. amount
- \ SWAP \put it back
- \ 3 - ; \adjust string length and finished
-
- \get characters from string and convert to an n digit number
-
- : NUMBER_GET \sinfo n1 --- sinfo n2
- SSPLIT
- DECIMAL-BIN
- -IF
- CRLF
- "Invalid number...Abort..." \the fatal error msg
- SPRINT
- REBOOT \its a fatal error...return to DOS
- THEN ;
-
- : 3BYTE# \sinfo --- sinfo
- 3 NUMBER_GET
- OUTPUT_COUNT ! ;
-
- PAGE
-
- \: 2_CONV
- \ OVER 2 DECIMAL-BIN DROP ; \subprocess for next words
- \
- \: TWO_ADJ \another subprocess
- \ SWAP 2+ SWAP 2 - ;
-
- \: TWO_2CHR# \sinfo --- sinfo row colm
- \ 2_CONV
- \ >R \save in return stack
- \ TWO_ADJ \adjust string addr
- \ \1st byte finished
- \ 2_CONV
- \ >R
- \ TWO_ADJ
- \ R> R> \get nos. back to stack
- \ SWAP ; \put them in correct order and done
- \
-
- : 2CHR# \sinfo --- sinfo n1
- 2 NUMBER_GET ;
-
- : TWO_2CHR# \sinfo --- sinfo n1 n2
- 2CHR# >R
- 2CHR# R> SWAP ;
-
- PAGE
-
- \: FOUR.NUMBERS \sinfo --- sinfo sr sc er ec
- \ 2_CONV
- \ >R
- \ TWO_ADJ
- \ \1st byte
- \ 2_CONV
- \ >R
- \ TWO_ADJ
- \ \2nd byte
- \ 2_CONV
- \ >R
- \ TWO_ADJ
- \ \3rd byte
- \ 2_CONV
- \ >R
- \ TWO_ADJ
- \ \4th byte
- \ R> R> R> R> \get data back to stack
- \ SWAP \reorder values
- \ DSWAP
- \ SWAP ;
-
- \define temp no. storage
- NUM1 DSW
- NUM2 DSW
- NUM3 DSW
- NUM4 DSW
-
- : FOUR.NUMBERS \sinfo --- sinfo n1 n2 n3 n4
- 2CHR# NUM1 ! \get 1st no
- 2CHR# NUM2 ! \2nd no
- 2CHR# NUM3 ! \3rd no
- 2CHR# NUM4 ! \4th no
- NUM1 @ \put result nos. on stack
- NUM2 @
- NUM3 @
- NUM4 @ ;
-
- : NO_TEXT_MSG
- "Text exhausted"
- FPRINTS+CRS ;
-
- : PROGRAMMED_END \for debug
- "Programmed end of text.."
- FPRINTS+CRS ;
-
- PAGE
-
- : NORMZ \ --- flg
- NORM 3BYTE# 1 ;
-
- : REVERSEZ \ --- flg
- REVERSE 3BYTE# 1 ;
-
- : BLINKZ \ --- flg
- BLINK 3BYTE# 1 ;
-
- : INTENSZ \ --- flg
- INTENS 3BYTE# 1 ;
-
- : SDELAY1 \ --- flg
- 1 SET_DELAY ;
-
- : SDELAY2 \ --- flg
- 2 SET_DELAY ;
-
- : SDELAY3 \ --- flg
- 8 SET_DELAY ;
-
- : SDELAY4 \ --- flg
- 10 SET_DELAY ;
-
- : RESET_DELAY \ --- flg
- 0 SET_DELAY ;
-
- : CLSZ \ --- flg
- CLS 0 ;
-
- : >CURSOR \ --- flg
- TWO_2CHR#
- PUT_CURS 0 ;
-
- : RETMSGZ \ --- flg
- RETMSG 0 ;
-
- : LENGTH \ --- flg
- 3BYTE# 1 ;
-
- : BELZ \ --- flg
- BEL 0 ;
-
- : DO_DELAY \ --- flg
- DELAY 0 ;
-
- PAGE
-
- : BOXZ \draw box from script entry
- TWO_2CHR# >R >R
- TWO_2CHR# R> R>
- SSWAP
- BOX 0 ;
-
- : 1ST_PAGE \switch to page #1 --- flg
- 0 SET_PAGE# 0 ;
-
- : 2ND_PAGE \switch to page #2 (CGA only) --- flg
- 1 SET_PAGE# 0 ;
-
- : TONE_ON \ --- flg
- 3BYTE#
- OUTPUT_COUNT @
- TONE ;
-
- : TONE_ON_0 \ --- flg
- TONE_ON 0 ;
-
- : TONE_OFF \ --- flg
- OFF 0 ;
-
- : TONE_BURST \ --- flg
- TONE_ON \freq, in cps
- 200 \wait for awhile..timer tick
- DO \is too slow, so use empty loop
- LOOP \AT machines will be higer pitched
- TONE_OFF ;
-
- \clear desired screen area
- : CLR_SOME \ --- flg
- FOUR.NUMBERS
- CLR 0 ;
-
- : TXT_END \script says this is end
- PROGRAMMED_END
- SET_EXIT 0 ;
-
- PAGE
-
- : SCRIPT_ACTION \perform proper action according to script
- \file character. ---
- CASE
- 'a' NORMZ \normal output
- 'b' REVERSEZ \reverse video
- 'c' BLINKZ \blink video
- 'd' INTENSZ \hi intensity video
- \
- 'e' RESET_DELAY \no inter char delay
- \
- 'f' SDELAY1 \shortest delay
- 'g' SDELAY2 \longer delay
- 'h' SDELAY3 \yet longer delay
- 'i' SDELAY4 \longest delay
- \
- 'j' CLSZ \clear screen & home
- 'k' >CURSOR \move cursor
- 'l' RETMSGZ \halt and wait for prompted input
- 'm' LENGTH \output a string of char
- 'n' BELZ \make a bel
- 'o' DO_DELAY \execute programmed delay
- 'p' BOXZ \draw a box
- 'q' 1ST_PAGE \switch to disp. page#1
- 'r' 2ND_PAGE \switch to disp. page#2
- 's' TONE_ON_0 \make programmed tone
- 't' TONE_OFF \turn tone off
- 'u' TONE_BURST \tone on/off
- 'v' CLR_SOME \clr desired part of screen
- 'X' TXT_END \this is the end of script cmmd.
- \
- NOCASE $$FALSE
- ENDCASE EXECUTE ;
- PAGE
-
- : ?TXT_LEN \n1 n2 n3 --- n1 n2 n3 n1
- 3 PICK ;
-
- : SMALLEST_LEN \ --- n1
- OUTPUT_COUNT @
- ?TXT_LEN MIN ;
-
- \sinfo(txt) sinfo(scrpt) flg --- sinfo(txt) sinfo(scrpt)
- : OUTPUT_TEXT
- IF \output text if flg is 1
- SSWAP \exchange sinfos
- OVER \get addr..sinfo underneath
- SMALLEST_LEN \select smallest len
- >R I \save in ret. stk
- CPRINTS \output sinfo text
- I - \
- I +2ND \
- SSWAP \exchange sinfos
- OUTPUT_COUNT @ \see if len is different
- R> \
- DDUP > \
- IF - \if so set count = 0
- ELSE DDROP 0
- THEN OUTPUT_COUNT !
- THEN ;
-
- : ?NEW_TXT \refresh txt buf?
- DROP3RD/4TH
- READ_TEXT_FILE
- ?TXT_LEN
- OUTPUT_COUNT @ >
- IF
- OUTPUT_COUNT @
- OUTPUT_TEXT
- SSWAP
- ?TXT_LEN
- 0=
- ?USER_KEY
- ELSE
- NO_TEXT_MSG 1
- THEN ;
-
- : ?TXT_DONE \ --- flg
- ?TXT_LEN \remaining text len
- -IF \test if len = 0
- brk1: \label for FDT86 debugger
- ?NEW_TXT \refresh text buf?
- ELSE 0 \else nothing
- THEN ;
-
- PAGE
-
- : PROCESS_TXT_INTERVAL \sinfo(txt) sinfo(scrpt) ---
- CGET \get script char
- SCRIPT_ACTION \perform the script action
- OUTPUT_TEXT ; \output text according
- \to script control
-
- : SCRIPT_DONE \ ---
- "Script exhausted"
- FPRINTS+CRS
- SET_EXIT ;
-
- : EXECUTE_ONE_SCRIPT \get a script & execute it
- SLEN
- IF
- PROCESS_TXT_INTERVAL
- ELSE SCRIPT_DONE
- THEN ;
-
- : ?END_PROCESS
- ?TXT_DONE \text file exhausted?
- EXIT_FLG @ \user or other exit?
- FOR ; \either condition?
-
- : PROCESS_ALL_TXT \sinfo(txt) sinfo(scrpt) ---
- BEGIN
- EXECUTE_ONE_SCRIPT \output one text segment
- ?END_PROCESS \is there more?
- UNTIL
- SDROP SDROP ; \throw away all sinfo
-
- EQUIPMENT DW 0:410H \DOS equipment addr
-
- : SET_CGA/MONO \ensure correct crt mode; ---
- EQUIPMENT @
- 30H FAND
- 30H =
- IF 80x25_MONO
- ELSE 80x25_BW
- THEN
- SET_VIDEO_MODE ;
-
- : INIT \intialize variables, screen etc..
- INIT_TIMER \save int vector addresses
- SET_CGA/MONO \make sure screen is compatible
- 1ST_PAGE DROP \make sure first display page
- EXIT_FLG 0! ; \clear exit flag
-
-
- PAGE
-
- \DOS level command to run this application is:
- \DRIVER DEMO.TXT SCRIPT.SCR<cr>
- \Batfile command is: RUNDEMO
- \MAIN is entry point and top application word
-
- : MAIN \type demo.txt under control
- \of the script file
- INIT \reset exit
- OPEN_FILES \open text & script files
- READ_FILES
- PROCESS_ALL_TXT \output formatted text 'til
- CLOSE_FILES \exhausted..back to DOS..
- SCALE_UP/DOWN ; \wind up w/ the scales
-
- \This is the application end. We hope you can see how
- \powerful and easy FUTURE86 can make your projects...
-
- END MAIN
-
-